package com.ruixing.newcourt.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.ruixing.newcourt.Bean.NewsBean;
import com.ruixing.newcourt.R;

import java.util.List;

/**
 * Created by LuoZhihao on 2018/11/14.
 */
public class NewsAdapter extends BaseAdapter {

    List<NewsBean> list;
    Context mContext;

    public NewsAdapter(Context context, List<NewsBean> mList){
        super();
        mContext = context;
        list = mList;
    }

    @Override
    public int getCount() {
        return 999999999;
    }

    @Override
    public Object getItem(int i) {
        return list.get(i%10);
    }

    @Override
    public long getItemId(int i) {
        return i%10;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {

        LayoutInflater inflater = LayoutInflater.from(mContext);
        View newsView = inflater.inflate(R.layout.item_news,null);
        TextView content = (TextView)newsView.findViewById(R.id.content);
        content.setText(list.get(0).getData().get(i%10).getTitle()+"\u3000\u3000"+list.get(0).getData().get(i%10).getAdddate().substring(0,list.get(0).getData().get(i%10).getAdddate().length()-8));

        return newsView;
    }
}
